// -----------------------------------------------------------------------------
// M A R I T I M E   R E S E A R C H   I N S T I T U T E   N E T H E R L A N D S
// -----------------------------------------------------------------------------
// Copyright (C) January 4, 2010 MARIN - All rights reserved - http://www.marin.nl
// -----------------------------------------------------------------------------
// Program  :
// Module   :
// File     : PulseFactory.cpp
// -----------------------------------------------------------------------------

#ifndef _WINDOWS
#include "mermaid.h"
#endif
#include "PulseFactory.h"

// all geometry and pulse types
#include "MathGeometry.h"
#include "ShipGeometry.h"
#include "MathPulse.h"
#include "ShipPulse.h"

#include "assertplus.h"

// -----------------------------------------------------------------------------
// function PulseFactory::create
// -----------------------------------------------------------------------------
/// constructor
/** detailed description */
// -----------------------------------------------------------------------------
Pulse* PulseFactory::create(Geometry* a_pGeometry, ///< abstract geometry to use
                            double a_dx,           ///< e-w grid spacing
                            double a_dy)           ///< n-s grid spacing
{
    MathGeometry *pMath = dynamic_cast<MathGeometry*>(a_pGeometry);
    if (pMath)
    {
        return new MathPulse(*pMath, a_dx, a_dy);
    }
    else
    {
        ShipGeometry *pShip = dynamic_cast<ShipGeometry*>(a_pGeometry);
        if (pShip)
        {
            return new ShipPulse(*pShip, a_dx, a_dy);
        }
        else
        {
            ASSERTFALSE();
        }
    }
    return 0;
}
